package com.tang.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * @Author tang jun liang
 * @Date 2023/4/22 22:27
 */
@Getter
public enum FieldType {
    /**
     * 用户状态
     */
    BASE(9001, "java自带的"),
    CUSTOMIZE(9101, "自定义枚举类型")
    ;


    @JsonValue
    @EnumValue
    private final Integer value;

    private final String desc;

    FieldType(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }


    @JsonCreator
    public static FieldType create(Integer value){
        for (FieldType item: values()){
            if (item.getValue().equals(value)){
                return item;
            }
        }
        return BASE;
    }
}
